<template>
  <div>
    <van-nav-bar
      title="文章详情"
      fixed
      placeholder
      left-arrow
      @click-left="onClickLeft"
    />
    <div class="title">
      <h3>{{ comment.news.title }}</h3>
    </div>
    <!-- 信息 -->
    <div class="info">
      <!-- 头像 -->
      <van-image round fit="cover" :src="comment.user.profile_photo" />
      <div class="userinfo">
        <div class="name">{{ comment.user.user_name }}</div>
        <!-- <div class="time">{{ comment.user.create_date | relvTime }}</div> -->
        <div class="time">{{ comment.user.create_date }}</div>
      </div>
      <div class="right">
        <van-button icon="plus" round type="primary">关注</van-button>
      </div>
    </div>
    <!-- 文章内容 -->
    <div class="content" v-html="comment.news.content"></div>
    <van-divider>end</van-divider>
    <!-- button喜欢 -->
    <div class="choseLike">
      <van-button icon="good-job-o" round type="primary">点赞</van-button>
      <van-button icon="delete-o" round type="primary">不喜欢</van-button>
    </div>
    <comments />
  </div>
</template>

<script>
import { articleDetailsAPI } from '@/api'
import comments from '@/views/comment/comment.vue'
export default {
  name: 'myArticle',
  data () {
    return {
      comment: {
        news:[],
        user:[],
      }
    }
  },
  components: {
    comments
  },
  async created () {
    const res = await articleDetailsAPI(this.$route.params.id)
    this.comment = res.data.data
    console.log('文章详情', res)
    console.log('comment:', this.comment)
  },
  methods: {
    onClickLeft () {
      this.$router.back()
    }
  }
}
</script>

<style lang="less" scoped>
.title {
  width: 100%;
}
.info {
  margin-left: 20px;
  margin-right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .van-image {
    width: 80px;
    height: 80px;
  }
  .userinfo {
    flex: 1;
    margin-left: 20px;
    .name {
      font-size: 14px;
    }
    .time {
      font-size: 14px;
    }
  }
  .right {
    .van-button {
      background-color: #258cf7;
    }
  }
}
.content {
  font-size: 18px;
  // width: 100%;
  * {
    word-wrap: break-word;
    white-space: normal;
    white-space: break-all;
  }
  ::v-deep table {
    overflow: auto;
  }
  ::v-deep p {
    word-wrap: break-word;
    white-space: break-all;
  }
  ::v-deep pre {
    overflow: auto;
    color: #fff;
    background-color: black;
    font-size: 16px;
  }
  ::v-deep strong {
    white-space: break-all;
    word-wrap: break-word;
  }
  ::v-deep img {
    width: 100%;
    height: auto;
  }
}
.choseLike {
  padding-left: 20px;
  padding-right: 20px;
  margin-bottom: 60px;
  // background-color: orange;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bottom {
  width: 100%;
  height: 40px;
  position: fixed;
  bottom: 0px;
  left: 0;

  .van-cell-group {
    line-height: 40px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-content: center;
    padding-left: -20px;
    padding-right: -20px;
    .van-button {
      width: 68px;
      height: 36px;
    }
  }
}
</style>
